<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtiframe.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Route_Job_Edit2 extends Page
{
       public $JS_StateChangeEditLoc = null;
       public $JS_StateChangeAddLoc = null;
       public $lblLocation = null;
       public $Label15 = null;
       public $Label26 = null;
       public $Label17 = null;
       public $lblLocationadd = null;
       public $lblClientadd = null;
       public $lblLoc = null;
       public $lblClient = null;
       public $hfError = null;
       public $JSValidate = null;
       public $Label35 = null;
       public $Label34 = null;
       public $cmbasst2 = null;
       public $Label33 = null;
       public $cmbdr2 = null;
       public $Label32 = null;
       public $cmbasst1 = null;
       public $Label31 = null;
       public $cmbdr1 = null;
       public $Label30 = null;
       public $Button1 = null;
       public $Label29 = null;
       public $Label27 = null;
       public $Label28 = null;
       public $Label9 = null;
       public $Label8 = null;
       public $JSAutoFillAJAX = null;
       public $Label19 = null;
       public $Label6 = null;
       public $JTEnd = null;
       public $JTstart = null;
       public $btnCancel = null;
       public $btnUpdate = null;
       public $btnUpdateLocation = null;
       public $btnclose = null;
       public $JTDivUpdateLocation = null;
       public $edClientadd = null;
       public $edTotaladd = null;
       public $edStartHrsadd = null;
       public $Label25 = null;
       public $edStopMinadd = null;
       public $edStopHrsadd = null;
       public $edStartMinadd = null;
       public $Label24 = null;
       public $Label23 = null;
       public $edMilesadd = null;
       public $edArrivalOdadd = null;
       public $Label22 = null;
       public $Label21 = null;
       public $edLastOdadd = null;
       public $edHrsadd = null;
       public $Label20 = null;
       public $Label18 = null;
       public $edLocationadd = null;
       public $edJobNo = null;
       public $Label16 = null;
       public $edClient = null;
       public $memoDesc = null;
       public $Label11 = null;
       public $edTot = null;
       public $edStartHrs2 = null;
       public $Label14 = null;
       public $edStopMin2 = null;
       public $edStopHrs2 = null;
       public $edStartMin2 = null;
       public $Label13 = null;
       public $edHrs2 = null;
       public $Label12 = null;
       public $Label7 = null;
       public $Label5 = null;
       public $edMileage = null;
       public $Label10 = null;
       public $edOdstop = null;
       public $edOdStart = null;
       public $cmbveh = null;
       public $Label4 = null;
       public $Label3 = null;
       public $hiddenDefault = null;
       public $JTJavaScript1 = null;
       public $hiddenLocId = null;
       public $btnDivShow = null;
       public $JTFrameLocation = null;
       public $JTDivAddLocation = null;
       public $btnDivHide = null;
       public $btnAddLocation = null;
       public $edTotal = null;
       public $edStartHrs = null;
       public $Label2 = null;
       public $edStopMin = null;
       public $edStopHrs = null;
       public $edStartMin = null;
       public $Label1 = null;
       public $lblMiles = null;
       public $edMiles = null;
       public $edArrivalOd = null;
       public $lbArrivalOd = null;
       public $edLastOd = null;
       public $edHrs = null;
       public $lblHrs = null;
       public $edLocation = null;
       public $hiddenExist = null;
       public $hiddenNewCount = null;
       public $hiddenJob = null;
       public $imgBack = null;
       public $hiddenEmp = null;
       public $hiddenRoute = null;
       public $Image3 = null;
       public $JTSiteTheme1 = null;

       function edStopMinaddJSBlur($sender, $params)
       {
       echo $this->edStartHrsadd->ajaxCall("computeHrsUpdate");
       ?>
       //Add your javascript code here

       <?php

       }

       function Button1JSClick($sender, $params)
       {

       ?>
       var newNumber = document.getElementById('JTFrameLocation').contentDocument.getElementById('hfNumbering').value;
       alert(newNumber);
       <?php

       }

       function Route_Job_Edit2JSLoad($sender, $params)
       {

       ?>
       autofill('edit');
       return false;

       <?php

       }





       function edArrivalOdaddJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit2.edMilesadd.value = (document.Route_Job_Edit2.edArrivalOdadd.value) - (document.Route_Job_Edit2.edLastOdadd.value);
       <?php

       }

       function edLastOdaddJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit2.edMilesadd.value = (document.Route_Job_Edit2.edArrivalOdadd.value) - (document.Route_Job_Edit2.edLastOdadd.value);
       <?php

       }

       function edStopMinaddJSKeyUp($sender, $params)
       {
       echo $this->edStopMinadd->ajaxCall("computeHrsUpdate");
       ?>
       //Add your javascript code here

       <?php

       }


       function edStopHrsaddJSKeyUp($sender, $params)
       {
       echo $this->edStartHrsadd->ajaxCall("computeHrsUpdate");
       ?>
       //Add your javascript code here

       <?php

       }



       function btncloseJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivUpdateLocation').Hide();
       return false;
       <?php

       }

       function edStopMinJSKeyUp($sender, $params)
       {
       echo $this->edStopMin->ajaxCall("computeHrs");
       ?>
       //Add your javascript code here

       <?php

       }

       function edStopHrsJSKeyUp($sender, $params)
       {
       echo $this->edStopMin->ajaxCall("computeHrs");
       ?>
       //Add your javascript code here

       <?php

       }


       function edOdStartJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit.edMileage.value = (document.Route_Job_Edit.edOdstop.value) - (document.Route_Job_Edit.edOdStart.value);
       <?php

       }

       function edOdstopJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit.edMileage.value = (document.Route_Job_Edit.edOdstop.value) - (document.Route_Job_Edit.edOdStart.value);
       <?php

       }

       function edStopMin2JSBlur($sender, $params)
       {
       echo $this->edStopMin2->ajaxCall("computeHrs2");
       ?>
       //Add your javascript code here

       <?php

       }

       function edStopHrs2JSBlur($sender, $params)
       {
       echo $this->edStopMin2->ajaxCall("computeHrs2");
       ?>
       //Add your javascript code here

       <?php

       }

       function btnUpdateLocationJSClickOld($sender, $params)
       {
       echo $this->btnUpdateLocation->ajaxCall('upLocation');
       ?>
       alert('Location successfully updated!');
       autofill('edit');
       document.getElementById('JTDivUpdateLocation').Hide();
       document.getElementById('JTFrameLocation').src='route_job_loc_list.php?type=e'
       return false;
       <?php
       }
       function btnUpdateLocationJSClick($sender, $params)
       {
       ?>
       xmlhttp=GetXmlHttpObject();
       if (xmlhttp==null)
       {
         alert ("Your browser does not support AJAX!");
         return;
       }
       var hf_route = document.getElementById('hiddenRoute').value;
       var job_no = escape(document.getElementById('edJobNo').value);
       var location = document.getElementById('edLocationadd').value;
       var s_hr = document.getElementById('edStartHrsadd').value;
       var s_min = document.getElementById('edStartMinadd').value;
       var last_od = document.getElementById('edLastOdadd').value;
       var client = document.getElementById('edClientadd').value;

       var stop_hrs=document.getElementById('edStopHrsadd').value;
       var stop_min=document.getElementById('edStopMinadd').value;
       var total_hrs=document.getElementById('edHrsadd').value;
       var hrs=document.getElementById('edTotaladd').value;
       var arrival_odometer=document.getElementById('edArrivalOdadd').value;
       var miles=document.getElementById('edMilesadd').value;
       var loc_id=document.getElementById('hiddenLocId').value;

       var job_id=document.getElementById('hiddenJob').value;


       var url="route_job_locs_ajax2.php";
       url=url+"?rou="+hf_route;
       url=url+"&job="+job_no;
       url=url+"&loc="+location;
       url=url+"&shr="+s_hr;
       url=url+"&smi="+s_min;
       url=url+"&lod="+last_od;
       url=url+"&cli="+client;
       url=url+"&type=edit";

       url=url+"&sthr="+stop_hrs;
       url=url+"&stmi="+stop_min;
       url=url+"&thr="+total_hrs;
       url=url+"&hrs="+hrs;
       url=url+"&aod="+arrival_odometer;
       url=url+"&mil="+miles;
       url=url+"&lid="+loc_id;

       url=url+"&jid="+job_id;

       xmlhttp.onreadystatechange=StateChangeEditLoc;
       xmlhttp.open("GET",url,true);
       xmlhttp.send(null);
       <?php
       }
       function upLocation()
       {
       $query_up_loc = "UPDATE rou_job_loc_tbl
       SET
       company_id='".$_SESSION['company_id']."',
       location='".$this->edLocationadd->Text."',
       start_hrs='".$this->edStartHrsadd->Text."',
       start_min='".$this->edStartMinadd->Text."',
       stop_hrs='".$this->edStopHrsadd->Text."',
       stop_min='".$this->edStopMinadd->Text."',
       total_hrs='".$this->edHrsadd->Text."',
       hrs='".$this->edTotaladd->Text."',
       last_odometer='".$this->edLastOdadd->Text."',
       arrival_odometer='".$this->edArrivalOdadd->Text."',
       miles='".$this->edMilesadd->Text."',
       client = '".$this->edClientadd->Text."',
       edit_who='".$_SESSION['username']."'
       WHERE loc_id='".$this->hiddenLocId->getValue()."'";

       //die($query_up_loc);
       mysql_query($query_up_loc) or die("UPDATE LOC ".mysql_error());
       $this->JTFrameLocation->setURL('route_job_loc_list.php?type=e&jobid='.$this->hiddenJob->getValue());
       }

       function btnAddLocationJSClickOld($sender, $params)
       {
       echo $this->btnAddLocation->ajaxCall('addLocation');
       ?>
       alert('Location successfully added!');
       autofill('edit');
       var answer = confirm("Add another record?");
       if(answer)
       {
       document.getElementById('JTDivAddLocation').Show();
       }
       else
       {
       document.getElementById('JTDivAddLocation').Hide();
       }

       document.getElementById('JTFrameLocation').src='route_job_loc_list.php?type=e'
       return false;
       <?php

       }

       function btnAddLocationJSClick($sender, $params)
       {

       ?>
       xmlhttp=GetXmlHttpObject();
       if (xmlhttp==null)
       {
         alert ("Your browser does not support AJAX!");
         return;
       }
       var hf_route = document.getElementById('hiddenRoute').value;
       var job_no = escape(document.getElementById('edJobNo').value);
       var location = document.getElementById('edLocation').value;
       var s_hr = document.getElementById('edStartHrs').value;
       var s_min = document.getElementById('edStartMin').value;
       var last_od = document.getElementById('edLastOd').value;
       var client = document.getElementById('edClient').value;
       var url="route_job_locs_ajax2.php";
       url=url+"?rou="+hf_route;
       url=url+"&job="+job_no;
       url=url+"&loc="+location;
       url=url+"&shr="+s_hr;
       url=url+"&smi="+s_min;
       url=url+"&lod="+last_od;
       url=url+"&cli="+client;
       url=url+"&type=add";
       xmlhttp.onreadystatechange=StateChangeAddLoc;
       xmlhttp.open("GET",url,true);
       xmlhttp.send(null);
       <?php

       }

       function addLocation()
       {
       /*mysql_query("INSERT rou_job_loc_tbl
       (company_id,
       job_id,
       job_no,
       location,
       start_hrs,
       start_min,
       stop_hrs,
       stop_min,
       total_hrs,
       hrs,
       last_odometer,
       arrival_odometer,
       miles,
       client,
       edit_who)
       VALUES
       ('".$_SESSION['company_id']."',
       '".$this->hiddenRoute->getValue()."',
       '".$this->edJobNo->Text."',
       '".$this->edLocation->Text."',
       '".$this->edStartHrs->Text."',
       '".$this->edStartMin->Text."',
       '".$this->edStopHrs->Text."',
       '".$this->edStopMin->Text."',
       '".$this->edHrs->Text."',
       '".$this->edTotal->Text."',
       '".$this->edLastOd->Text."',
       '".$this->edArrivalOd->Text."',
       '".$this->edMiles->Text."',
       '".$this->edClient->Text."',
       '".$_SESSION['username']."')
       ");
       */
       mysql_query("INSERT rou_job_loc_tbl
       (company_id,
       job_id,
       job_no,
       location,
       start_hrs,
       start_min,
       last_odometer,
       client,
       edit_who)
       VALUES
       ('".$_SESSION['company_id']."',
       '".$this->hiddenRoute->getValue()."',
       '".$this->edJobNo->Text."',
       '".$this->edLocation->Text."',
       '".$this->edStartHrs->Text."',
       '".$this->edStartMin->Text."',
       '".$this->edLastOd->Text."',
       '".$this->edClient->Text."',
       '".$_SESSION['username']."')
       ");
       $this->JTFrameLocation->setURL('route_job_loc_list.php?type=e&jobid='.$this->hiddenJob->getValue());
       }
       function btnDivShowJSClick($sender, $params)
       {
       ?>

       document.getElementById('edClient').value = '';
       document.getElementById('edLocation').value = '';
       document.getElementById('edStartHrs').value = '';
       document.getElementById('edStartMin').value = '';
       document.getElementById('edStopHrs').value = '';
       document.getElementById('edStopMin').value = '';
       document.getElementById('edHrs').value = '';
       document.getElementById('edTotal').value = '';
       document.getElementById('edLastOd').value = '';
       document.getElementById('edArrivalOd').value = '';
       document.getElementById('edMiles').value = '';

       document.getElementById('hiddenDefault').value = 'c';
       document.getElementById('JTDivAddLocation').Show();
       document.getElementById('btnAddLocation').style.display='inline';
       //document.getElementById('btnUpdateLocation').style.left='9px';
	     //document.getElementById('btnUpdateLocation').style.display='none';
       var newNumber = document.getElementById('JTFrameLocation').contentDocument.getElementById('hfNumbering').value;
       document.getElementById('JTDivAddLocation_caption').innerHTML = "Location #"+newNumber;
       return false;
       <?php
       }

       function btnDivHideJSClick($sender, $params)
       {
       ?>
       document.getElementById('JTDivAddLocation').Hide();
       return false;
       <?php
       }

       function edStopHrsJSBlur($sender, $params)
       {
       echo $this->edStopMin->ajaxCall("computeHrs");
       }


       /*function edStopMinJSBlur($sender, $params)
       {
       echo $this->edStopMin->ajaxCall("computeHrs");
       }  */

       function computeHrs($sender, $params)
       {
       $startHrs = $this->edStartHrs->Text;
       $startMin = $this->edStartMin->Text;
       $endHrs = $this->edStopHrs->Text;
       $endMin = $this->edStopMin->Text;

       $start = strtotime($startHrs." hours ".$startMin." minutes");
       $end = strtotime($endHrs." hours ".$endMin." minutes");
       $answer = $end - $start;

       $this->edTotal->Text = date('H\h i\m',$answer);
       $ansMin = date('i',$answer);
       $ansHrs = date('H',$answer);
       $compAns =($ansMin/60) + $ansHrs;
       $this->edHrs->Text = $compAns;
       }


       function computeHrsUpdate($sender, $params)
       {
       $startHrs = $this->edStartHrsadd->Text;
       $startMin = $this->edStartMinadd->Text;
       $endHrs = $this->edStopHrsadd->Text;
       $endMin = $this->edStopMinadd->Text;

       $start = strtotime($startHrs." hours ".$startMin." minutes");
       $end = strtotime($endHrs." hours ".$endMin." minutes");
       $answer = $end - $start;

       $this->edTotaladd->Text = date('H\h i\m',$answer);
       $ansMin = date('i',$answer);
       $ansHrs = date('H',$answer);
       $compAns =($ansMin/60) + $ansHrs;
       $this->edHrsadd->Text = $compAns;
       }







        function computeHours($sender, $params)
       {
       $startHrs = $this->startHrs->Text;
       $startMin = $this->startMrs->Text;
       $stopHrs = $this->stopHrs->Text;
       $stopMin = $this->stopMin->Text;

       $start = strtotime($startHrs." hours ".$startMin." minutes");
       $stop = strtotime($stopHrs." hours ".$startMin." minutes");
       $hours = $stop - $start;

       $this->edTotal->Text = date('H\h i\m',$hours);
       $hoursMin = date('i',$hours);
       $hoursHrs = date('H',$hours);
       $compHrs = ($hoursMin/60) + $hoursHrs;
       $this->edHrs->Text= $compHrs;
       }


       function edArrivalOdJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit.edMiles.value = (document.Route_Job_Edit.edArrivalOd.value) - (document.Route_Job_Edit.edLastOd.value);
       <?php

       }

       function edLastOdJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Job_Edit.edMiles.value = (document.Route_Job_Edit.edArrivalOd.value) - (document.Route_Job_Edit.edLastOd.value);
       <?php

       }

       function btnCancelClick($sender, $params)
       {
       redirect('route_list2.php?emp='.$this->hiddenEmp->getValue().'&route='.$this->hiddenRoute->getValue());
       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }



       function computeHrs2($sender, $params)
       {
       $startHrs = $this->edStartHrs2->Text;
       $startMin = $this->edStartMin2->Text;
       $endHrs = $this->edStopHrs2->Text;
       $endMin = $this->edStopMin2->Text;

       $start = strtotime($startHrs." hours ".$startMin." minutes");
       $end = strtotime($endHrs." hours ".$endMin." minutes");
       $answer = $end - $start;

       $this->edTot->Text = date('H\h i\m',$answer);
       $ansMin = date('i',$answer);
       $ansHrs = date('H',$answer);
       $compAns =($ansMin/60) + $ansHrs;
       $this->edHrs2->Text = round($compAns,2);
       }






       function Route_Job_Edit2Create($sender, $params)
       {
       //$job_id = $_GET['job'];
       $emp_id = $_GET['emp'];
       $route_id = $_GET['route'];
       $this->hiddenEmp->setValue($emp_id);
       $this->hiddenRoute->setValue($route_id);
       $this->hiddenJob->setValue($route_id);

       $this->lblLoc->Caption = '';
       $this->lblClient->Caption = '';

       $this->JTFrameLocation->setURL('route_job_loc_list.php?type=e&jobid='.$this->hiddenRoute->getValue());

       if($_SESSION['access_route']==1)
       {
       $this->btnCancel->Visible=false;
       $this->btnUpdate->Visible=false;
       $this->btnDivShow->Visible=false;
       }

       if($_SESSION['access_route']==2)
       {
       $this->btnCancel->Visible=true;
       $this->btnUpdate->Visible=true;
       $this->btnDivShow->Visible=true;
       }


       $query_route = "select * from route_tbl where emp_id='".$this->hiddenEmp->getValue()."' and route_id='".$this->hiddenRoute->getValue()."'";
       $result_route_show = mysql_query($query_route)or die("SELECT ROUTE - " . mysql_error());
       $row_route = mysql_fetch_array($result_route_show);

       $this->JTstart->Text=$row_route['start_date'];
       $this->JTEnd->Text=$row_route['end_date'];
       $this->edStartHrs2->Text=$row_route['start_hrs'];
       $this->edStartMin2->Text=$row_route['start_min'];
       $this->edStopHrs2->Text=$row_route['stop_hrs'];
       $this->edStopMin2->Text=$row_route['total_hrs'];
       $this->edHrs2->Text=$row_route['hrs'];
       //$this->edShift->Text=$row_route['shift'];
       $this->edOdStart->Text=$row_route['odometer_start'];
       $this->edOdstop->Text=$row_route['odometer_stop'];
       $this->edMileage->Text=$row_route['miles'];
       $this->memoDesc->Text=$row_route['description'];
       $this->edJobNo->Text = $row_route['job_no'];

       //$veh_id = $row_route['veh_id'];
       //$result_vehid = mysql_query("select * from vehicle_tbl where company_id='".$_SESSION['company_id']."' and vehicle_id='".$veh_id."'");
       //$row_vehid = mysql_fetch_array($result_vehid);

       $this->cmbveh->Clear();
       $this->cmbveh->ItemIndex=$row_route['veh_id'];
       $result_veh = mysql_query("select * from vehicle_tbl where company_id='".$_SESSION['company_id']."'");
       //die($veh_id);

       while($row_veh = mysql_fetch_array($result_veh))
       {
        $this->cmbveh->AddItem($row_veh['veh_num'], null, $row_veh['vehicle_id']);
       }



        $this->cmbdr1->Clear();
        $this->cmbdr1->AddItem('--Select--', null, '0');

        $this->cmbdr2->Clear();
        $this->cmbdr2->AddItem('--Select--', null, '0');

        $this->cmbasst1->Clear();
        $this->cmbasst1->AddItem('--Select--', null, '0');

        $this->cmbasst2->Clear();
        $this->cmbasst2->AddItem('--Select--', null, '0');

        $result_emp = mysql_query("select * from employee_tbl where company_id='".$_SESSION['company_id']."'");

        while($row_emp = mysql_fetch_array($result_emp))
        {
            $this->cmbdr1->AddItem($row_emp['lname'].','.$row_emp['fname'], null, $row_emp['autoid']);
            $this->cmbdr2->AddItem($row_emp['lname'].','.$row_emp['fname'], null, $row_emp['autoid']);
            $this->cmbasst1->AddItem($row_emp['lname'].','.$row_emp['fname'], null, $row_emp['autoid']);
            $this->cmbasst2->AddItem($row_emp['lname'].','.$row_emp['fname'], null, $row_emp['autoid']);
        }

        $this->cmbdr1->AddItem('None', null, '0');
        $this->cmbdr2->AddItem('None', null, '0');
        $this->cmbasst1->AddItem('None', null, '0');
        $this->cmbasst2->AddItem('None', null, '0');

        $this->cmbdr1->ItemIndex=$row_route['dr1_id'];
        $this->cmbdr2->ItemIndex=$row_route['dr2_id'];
        $this->cmbasst1->ItemIndex=$row_route['asst1_id'];
        $this->cmbasst2->ItemIndex=$row_route['asst2_id'];





       //$this->edLocation->Text = $row_job['location'];
       //$this->edStartHrs->Text = $row_job['start_hrs'];
       //$this->edStartMin->Text = $row_job['start_min'];
       //$this->edStopHrs->Text = $row_job['stop_hrs'];
       //$this->edStopMin->Text = $row_job['stop_min'];
       //$this->edHrs->Text = $row_job['total_hrs'];
       //$this->edTotal->Text  =$row_job['hrs'];
       //$this->edLastOd->Text = $row_job['last_odometer'];
       //$this->edArrivalOd->Text = $row_job['arrival_odometer'];
       //$this->edMiles->Text = $row_job['miles'];
       //$this->edAmount->Text = $row_job['amt_billed'];
       //$this->edCollected->Text = $row_job['amt_collected'];
       //$this->memoComments->Text = $row_job['comments'];
       //$this->cmbAccount->ItemIndex = $row_job['account'];
       //$this->cmbPaymentType->ItemIndex = $row_job['payment_type'];

       $this->imgBack->setLink('route_list2.php?emp='.$this->hiddenEmp->getValue().'&route='.$this->hiddenRoute->getValue());


       /* $this->cmbAccount->Clear();
        $result_account = mysql_query("SELECT * FROM lookup_expense_tbl WHERE company_id='".$_SESSION['company_id']."' AND category='accounts'");

        while($row_account = mysql_fetch_array($result_account))
        {
            $this->cmbAccount->AddItem($row_account['value'], null, $row_account['value']);
        }

        $this->cmbPaymentType->Clear();
        $result_payment = mysql_query("SELECT * FROM lookup_personnel_tbl WHERE company_id='".$_SESSION['company_id']."' AND category='departments'");

        while($row_payment = mysql_fetch_array($result_payment))
        {
            $this->cmbPaymentType->AddItem($row_payment['value'], null, $row_payment['value']);
        } */

       }


       function btnUpdateClick($sender, $params)
       {
       $vehicle_id = $this->cmbveh->getItemIndex();
       $result_vehicle = mysql_query("SELECT * FROM vehicle_tbl WHERE vehicle_id='".$vehicle_id."'")
       or die("GET VEH_ID ".mysql_error());
       $row_veh = mysql_fetch_array($result_vehicle);

       mysql_query("update route_tbl set
       dr1_id = '".$this->cmbdr1->getItemIndex()."',
       dr2_id = '".$this->cmbdr2->getItemIndex()."',
       asst1_id = '".$this->cmbasst1->getItemIndex()."',
       asst2_id = '".$this->cmbasst2->getItemIndex()."',
       start_date = '".$this->JTstart->Text."',
       end_date = '".$this->JTEnd->Text."',
       start_hrs = '".$this->edStartHrs2->Text."',
       start_min = '".$this->edStartMin2->Text."',
       stop_hrs = '".$this->edStopHrs2->Text."',
       stop_min = '".$this->edStopMin2->Text."',
       total_hrs = '".$this->edHrs2->Text."',
       hrs = '".$this->edTot->Text."',
       odometer_start = '".$this->edOdStart->Text."',
       odometer_stop = '".$this->edOdstop->Text."',
       miles = '".$this->edMileage->Text."',
       description = '".$this->memoDesc->Text."'
       where emp_id ='".$this->hiddenEmp->getValue()."' and route_id = '".$this->hiddenRoute->getValue()."'")or die ("UPDATE ROUTE EDIT-".mysql_error());


       $query_update_locs = "UPDATE rou_job_loc_tbl SET job_id='".$this->hiddenRoute->getValue()."' WHERE company_id='".$_SESSION['company_id']."'
       AND edit_who='".$_SESSION['username']."' AND job_id='0'";
       mysql_query($query_update_locs) or die("UPDATE LOCS ".mysql_error());


       /*if($this->chkCompleted->Checked==true)
       {
       $completed = '1';
       }
       else
       {
       $completed = '0';
       }*/


       /*location='".$this->edLocation->Text."',
       start_hrs='".$this->edStartHrs->Text."',
       start_min='".$this->edStartMin->Text."',
       stop_hrs='".$this->edStopHrs->Text."',
       stop_min='".$this->edStopMin->Text."',
       total_hrs='".$this->edHrs->Text."',
       hrs = '".$this->edTotal->Text."',
       last_odometer='".$this->edLastOd->Text."',
       arrival_odometer='".$this->edArrivalOd->Text."',
       miles='".$this->edMiles->Text."',

       mysql_query("UPDATE rou_jobrecord_tbl SET
       job_no='".$this->edJobNo->Text."',
       account='".$this->cmbAccount->getItemIndex()."',
       comments='".$this->memoComments->Text."',
       amt_billed='".$this->edAmount->Text."',
       amt_collected='".$this->edCollected->Text."',
       payment_type='".$this->cmbPaymentType->getItemIndex()."',
       completed='".$completed."'
       WHERE job_id='".$this->hiddenJob->getValue()."'")or die ('UPDATE JOB -' . mysql_error());*/

       redirect('route_list2.php?emp='.$this->hiddenEmp->getValue().'&route='.$this->hiddenRoute->getValue());
       }


}

global $application;

global $Route_Job_Edit2;

//Creates the form
$Route_Job_Edit2=new Route_Job_Edit2($application);

//Read from resource file
$Route_Job_Edit2->loadResource(__FILE__);

//Shows the form
$Route_Job_Edit2->show();

?>